<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{time|timeFormat}}
    </div>
    <script src="./todomvc-app-template-master/node_modules/vue/dist/vue.js"></script>
    <script>
        // 插件
        var myPlugin = {
            // 安装
            install: (Vue)=> {
                Vue.filter("timeFormat", (val)=> {
                    let time = new Date(val)
                    let year = time.getFullYear()
                    let month = time.getMonth() + 1
                    let day = time.getDate();
                    return year + "年" + month + "月" + day + "号"
                })
            }
        }

        // 放到创建实例之前，这句话使用插件，就会自动执行插件中的install方法
        Vue.use(myPlugin)
        const app = new Vue({
            el:"#app",
            data: {
                time: "2022-02-16"
            }
        })

        
    </script>
</body>
</html>